Choose one of the following options for your open source data layer:
  • use the official Chainlit data layer (PostgreSQL + asyncpg)
  • leverage a community-based data layer
  • or build your own!

Official data layer

When using the official data layer, just add the DATABASE_URL variable to your .env and a cloud storage configuration if relevant.

Community data layers

For community data layers, you need to import the corresponding data layer in your chainlit app. Here is how you would do it with SQLAlchemyDataLayer:
import chainlit as cl

from chainlit.data.sql_alchemy import SQLAlchemyDataLayer

@cl.data_layer
def get_data_layer():
    return SQLAlchemyDataLayer(conninfo="...")

Custom data layers

Follow the reference for an exhaustive list of the methods your custom data layer needs to implement.

Cloud Storage Providers supported out-of-the-box

  • AWS S3
    • LocalStack via DEV_AWS_ENDPOINT environment variable
  • Azure
    • Blob Storage
    • Data Lake Storage (ADLS) Gen2
  • Google Cloud Storage
    • via Private Key
    • via Application Default Credentials (e.g. in Google Cloud Run)